@extends('template.adminpage')
@section('content')
<ol class="breadcrumb">
  <li><a href="{{URL::to('/agen')}}">Daftar agen</a></li>
  <li class="active">Bonus {{$agenid}}</li>
</ol>

<div class="container-black" style="background-color: #fff;">
    
  
        <label style="margin-top:10px"><u>Bonus</u></label>
      <div class="container-black-soft" style="background-color: #F0F0F0;">
        <br>
          



          <div class="row">
          <div class="col-md-8">
            <div class="col-lg-5">
            <label>Fee (komisi) referal</label>
            </div>
            <div class="col-lg-5">
              <input type="text"  class="form-control" placeholder="Rp" name="keyword" style="height:30px" value="Rp {{number_format($komisirefd,0,'.','.')}}" disabled /></input>
            </div>
            
          </div>
          </div>
          <br>


          <div class="row">
          <div class="col-md-8">
            <div class="col-lg-5">
            <label>Fee (komisi) penjualan (order)</label>
            </div>
            <div class="col-lg-5">
              <input type="text"  class="form-control" placeholder="Rp" name="keyword" style="height:30px" value="Rp {{number_format($komisiordd,0,'.','.')}}" disabled /></input>
            </div>
            
          </div>
          </div>
          <br>

            

    </div>

    <label style="margin-top:10px"><u>Summary</u></label>
        <br>
      <div class="table-responsive">
         <table class="table table-bordered table-hover">
          <thead>
            <tr>
              <th>No</th>
              <th>Jenis bonus</th>
              <th>Nominal</th>
              <th>Aksi</th>
            </tr>
          </thead>
          <tbody>
            <tr>
             <td>1</td>
             <td>Referal</td>
             <td>Rp {{number_format($komisi->bonus_referal,0,'.','.')}}</td>
             <td><a data-toggle="modal" data-target="#detailref"><button class="btn btn-xs btn-dark" ><span class="fa fa-file-text-o"></span> Detail</button></a></td>
            </tr>
            <tr>
             <td>2</td>
             <td>Penjualan</td>
             <td>Rp {{number_format($komisi->bonus_order,0,'.','.')}}</td>
             <td><a data-toggle="modal" data-target="#detailord"><button class="btn btn-xs btn-dark" ><span class="fa fa-file-text-o"></span> Detail</button></a></td>
            </tr>
            <tr>
             <td></td>
             <td>Total</td>
             <td>Rp {{number_format(($komisi->bonus_order+$komisi->bonus_referal),0,'.','.')}}</td>
             <td></td>
            </tr>
          </tbody>
        </table>
      </div>
    <br>

<br>
</div>


 <div class="modal fade" id="detailref" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="false">
    <div class="modal-dialog modal-lg">
      <div class="modal-content">
        <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>

        <h4 align="center" class="modal-title"> <label style="margin-top:5px; margin-bottom:25px">Detail komisi referal</label></h4>
        </div>
        <div align="left">
                  
                  <div class="row" style="margin-top:10px">
                  <div class="col-md-10 col-md-offset-1">
                  <div style="height:300px;overflow:auto;">
                   <table class="table table-bordered table-hover">
                    <thead>
                      <tr>
                        <th>No</th>
                        <th>Tanggal</th>
                        <th>Dari</th>
                        <th>Nominal</th>
                      </tr>
                    </thead>
                    <tbody>
                    <?php 
                        $no=1; 
                        $i=0; 
                    ?>
                    @foreach($komisireferal as $detail)
                    <tr>
                        <td>{{$no}}</td>
                        <td>{{date("d-M-Y",strtotime($detail->bonus_log_date))}}</td>
                        <td>Referensi agen <?php $agen = agen::where('agen_sponsor_id',$detail->bonus_log_agen_id)->skip($i)->take(1)->first();  echo $agen->agen_code; ?></td>
                        <td>Rp {{number_format($detail->bonus_log_referal,0,'.','.')}}</td>
                   </tr>
                    <?php $no++; $i++; ?>
                    @endforeach
                     <tr>
                      <td></td>
                      <td></td>
                      <td>Total</td>
                      <td>Rp {{number_format($komisi->bonus_referal,0,'.','.')}}</td>
                   </tr>
                     </tbody>
                  </table>



                  </div> 
                  </div> 
                  </div>   
        
        </div>
        <div class="modal-footer">

        <button class="btn btn-sm btn-dark" style="margin-right:5px" class="close" data-dismiss="modal"><span class="fa fa-times"></span> Batal</button></a>
             
        </div>
      </div>
    </div>
  </div>


 <div class="modal fade" id="detailord" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="false">
    <div class="modal-dialog modal-lg">
      <div class="modal-content">
        <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>

        <h4 align="center" class="modal-title"> <label style="margin-top:5px; margin-bottom:25px">Detail komisi order</label></h4>
        </div>
        <div align="left">
                  
                  <div class="row" style="margin-top:10px">
                  <div class="col-md-10 col-md-offset-1">
                  <div style="height:300px;overflow:auto;">
                  

                    <table class="table table-bordered table-hover">
                    <thead>
                      <tr>
                        <th>No</th>
                        <th>Tanggal</th>
                        <th>Dari</th>
                        <th>Nominal</th>
                      </tr>
                    </thead>
                    <tbody>
                    <?php 
                        $no=1; 
                        $i=0; 
                    ?>
                    @foreach($komisiorder as $detail)
                    <tr>
                        <td>{{$no}}</td>
                        <td>{{date("d-M-Y",strtotime($detail->bonus_log_date))}}</td>
                        <td><?php 
                          $order = order::where('order_agen_id',$detail->bonus_log_agen_id)->skip($i)->take(1)->first();  
                             if($order->order_name=='idcard'){$ordername = 'ID Card';}
                    else if($order->order_name=='packaging'){$ordername = 'Packaging';}
                    else if($order->order_name=='brochure'){$ordername = 'Brosur';}
                    else if($order->order_name=='nota'){$ordername = 'Nota';}
                    else if($order->order_name=='tshirt'){$ordername = 'T-Shirt';}
                          echo $ordername.' '.$order->order_qty.' '.$order->order_qty_unit; 
                          ?>
                      </td>
                        <td>Rp {{number_format($detail->bonus_log_order,0,'.','.')}}</td>
                   </tr>
                    <?php $no++; $i++; ?>
                    @endforeach
                     <tr>
                      <td></td>
                      <td></td>
                      <td>Total</td>
                      <td>Rp {{number_format($komisi->bonus_order,0,'.','.')}}</td>
                   </tr>
                     </tbody>
                  </table>



                  </div> 
                  </div> 
                  </div>   
        
        </div>
        <div class="modal-footer">

        <button class="btn btn-sm btn-dark" style="margin-right:5px" class="close" data-dismiss="modal"><span class="fa fa-times"></span> Batal</button></a>
             
        </div>
      </div>
    </div>
  </div>
@stop
@stop